package com.gjy.poi.use;

import com.gjy.poi.ExcelDataHandler;
import com.google.common.collect.Sets;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Set;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-06-06 09:27:04
 */
public class ExcelTest {

    @Test
    public void test4() throws Exception {
        String s = "D:\\工作日程安排\\2023年\\全员营销\\端午-全员营销\\雨析报表\\DataReportExcel-wgZQZsySk7xMQ3at20230603094342877.xlsx";
        InputStream inputStream = Files.newInputStream(Paths.get(s));

        Workbook workbook = new XSSFWorkbook(inputStream);
        Sheet sheet = workbook.getSheetAt(0);

        for (Row row : sheet) {
            String s1 = row.getCell(1).getStringCellValue();
            System.out.println(s1);
        }
    }

    @Test
    public void test3() throws Exception {
        String s = "D:\\yurun\\MES-养殖\\接口设计\\response2.xlsx";
        InputStream inputStream = Files.newInputStream(Paths.get(s));

        Workbook workbook = new HSSFWorkbook(inputStream);
        Sheet sheet = workbook.getSheetAt(0);

        for (Row row : sheet) {
            String s1 = row.getCell(1).getStringCellValue();
            System.out.println(s1);
        }
    }

    @Test
    public void test2() throws IOException {
        Set<String> diff = ExcelDataHandler.diff(
                "D:\\工作日程安排\\2023年\\全员营销\\端午-全员营销\\雨析报表\\DataReportExcel-wgZQZsySk7xMQ3at20230603094342877.xlsx",
                "D:\\工作日程安排\\2023年\\全员营销\\端午-全员营销\\雨析报表\\DataReportExcel-Vhi3ase8zB6fuw0R20230606091141962.xlsx",
                12);
        System.out.println(diff);
    }

    @Test
    public void test1() {
        HashSet<Integer> s1 = Sets.newHashSet(1, 2, 3);

        HashSet<Integer> s2 = Sets.newHashSet(2, 3, 4);

        System.out.println(Sets.difference(s1, s2));
    }
}
